/*
 * QAgent.h
 *
 *  Created on: 6 mei 2013
 *      Author: Wietse
 */


#ifndef QAGENT_H_
#define QAGENT_H_
#include "../Definitions.h"
#ifdef SWARM_AGENT

#include <vector>
#include "../Data.h"
#include "../Position.h"
#include "../Crawler.h"

class Swarm;

//Struct that saves the ID of a vehicle and the position.
struct VehicleData {
	int ID;
	Position	position;
};

enum SWARM_AGENT_STATE {
	STICKWITHCENTEROFNEARBYCRAWLERS,
	GOTORANDOMPOSITION
};

class QAgent {
public:
				QAgent();
				QAgent(Position*);
	virtual 	~QAgent();
	Position 	calculateTarget(Swarm*, Position*, std::vector<Data> *, double);	//Calculates the position the Quadcopter needs to move towards. This function implements the agent.
private:
	void						getData(Swarm*, Position*, std::vector<Data> *);	//Gets the quadcopter positions from data vector and the positions from the crawlers that are nearby
	int							getNumOfNearbyCrawlers(Position*, Swarm*);
	int							getNumOfNearbyQuadcopters(Position*);
	std::vector<VehicleData*>	getNearbyQuadcopters(Position*);							//Returns vector of quadcopters that are nearby
	std::vector<Crawler*>	getNearbyCrawlers(Position*, Swarm*);								//Returns vector of crawlers that are nearby
	Position					getCenterOfNearbyCrawlers(Position*, Swarm*);						//Returns the center of nearbyCrawlers, only useful when there are nearby crawlers
	bool						trueByChance(int p);
	bool						quadcopterNearby(Position *currentPosition);
	Position					getRandomPosition();
	Position					calculateRandomNearbyPosition(Position*);							//Calculates a random nearby position, that isn't well covered

	std::vector<VehicleData> 	quadcopters;
	std::vector<VehicleData> 	crawlers;
	Position 					target;
	double						decisionTimer;
	enum SWARM_AGENT_STATE		state;
};
#endif

#endif /* QAGENT_H_ */



